﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using QL_DTTN.DAL;
namespace QL_DTTN.DTO.DTO
{
    public partial class HeDaoTao
    {
        public HeDaoTao GetHeDaoTao(short maHeDaoTao)
        {
            bool kt = false;
            string sql = " select MaHeDaoTao,TenHeDaoTao from " + _tableName + " where MaHeDaoTao=@pMaHeDaoTao ";
            SqlDataProvider dp = new SqlDataProvider();
            dp.AddParameter(new SqlParameter("@pMaHeDaoTao", maHeDaoTao));
            System.Data.SqlClient.SqlDataReader sqlRr = dp.ExDataReader(sql, true);
            HeDaoTao dt = new HeDaoTao();
            if (sqlRr != null)
            {
                while (sqlRr.Read())
                {

                    if (!Convert.IsDBNull(sqlRr["MaHeDaoTao"])) dt.MaHeDaoTao = Convert.ToInt16(sqlRr["MaHeDaoTao"]);
                    if (!Convert.IsDBNull(sqlRr["TenHeDaoTao"])) dt.TenHeDaoTao = sqlRr["TenHeDaoTao"].ToString();
                    kt = true;
                }
                dp.CloseConnection();
                if (kt) return dt;
                else return null;
            }
            else
            {
                return null;
            }
        }
    }
}
